package com.spring4all.service.impl;

import com.spring4all.entity.UserDO;
import com.spring4all.repository.UserRepository;
import com.spring4all.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Primary
@Slf4j
public class BaseUserService implements UserService {

    @Resource
    private UserRepository userRepository;

    @Override
    public void insert(UserDO userDO) {
       userRepository.save(userDO);
    }

    @Override
    public UserDO getByUsername(String username) {
        return userRepository.findByUsername(username);
    }

    @Override
    public int validatePhone(String phone, String code) {
        if (phone.contains(code)) {
            return 1;
        }
        return 0;

    }

}
